

import type { ValidateFieldsError } from 'async-validator';
import { FilterMethods, Filters, TableColumnCtx } from 'element-plus/lib/components/table/src/table-column/defaults';
import { TableProps } from 'element-plus/lib/components/table/src/table/defaults';
import { Socket } from 'socket.io-client';
import { InjectionKey, Ref, VNode } from 'vue';
import { Store } from 'vuex';
import Alymodel from './mysql_interface/model';
import Study from './mysql_interface/studycodemodel';
export const Storekey: InjectionKey<Store<Istate>> = Symbol()

export interface Iquestion extends Study.Iquestion {
    ACcount?: number,
    userquestioncount?: number
}

export interface Irunactivityoption {
    activityid: number | undefined;
    index: number;
    length: number;
}

export interface Istate {
    user?: Study.Iuser,
    users?: { count: number, rows: Study.Iuser[] },
    question?: { count: number, rows: Iquestion[] },
    activity?: { count: number, rows: Study.Iactivity[] },
    article?: { count: number, rows: Study.Iarticle[] },
    questionbank?: { count: number, rows: Study.Iquestionbank[] },
    label?: { count: number, rows: Study.ILabel[] },
    team?: { count: number, rows: Study.Iteam[] }
    myteam?: Study.Iteam,
    myuserquestion?: Study.Iuserquestion[]
    state?: {
        difficulty: { '1': '入门', '2': '普及-', '3': '普及/提高-', '4': '普及+/提高', '5': '提高+', '6': '省选', '7': 'NOI/NOI+/CTSC' }
    },
    socket: Socket
    notice?: { count: number, rows: Study.Inotice[], isseecount: number }
    packegekey?: { count: number, rows: Alymodel.IMagentkey[] }
    specialjudge?: { count: number, row: Study.Ispecialjudge }
    science?: boolean,
    time?: number,
    myPractiseQuestion?: { questionid: number, userid: number, question: Study.Iquestion }[],
    indexsocket?: Socket
    onlineUser?: { userid: number, teamid: number }[]
}

declare type CI<T> = {
    column: TableColumnCtx<T>;
    $index: number;
};

export interface Imyreq<T> {
    count: number;
    rows: T[];
}

export interface ITable<T = { ID: number }> extends TableProps<T> {
    sortable: 'DESC' | 'ASC'
    limit: number
    offset: number
    order: keyof T
    like: string | number
    tableu?: TtableU<T>[]
}

export type KImodel<T> = keyof T

interface fn {
    (...args: any[]): any;
}
interface AnyObject {
    [key: string]: any;
}
interface WatcherPropsData {
    data: Ref<any[]>;
    rowKey: Ref<string>;
}

interface fn1<T> {
    (v: T): any
}

export interface TtableU<T> {
    id?: string;
    realWidth?: number;
    type?: string;
    label?: string;
    className?: string;
    labelClassName?: string;
    property?: string;
    prop?: KImodel<T>;
    width?: string | number;
    minWidth?: string | number;
    renderHeader?: (data: CI<T>) => VNode;
    sortable?: boolean | string;
    sortMethod?: (a: T, b: T) => number;
    sortBy?: string | ((row: T, index: number) => string) | string[];
    resizable?: boolean;
    columnKey?: string;
    rawColumnKey?: string;
    align?: string;
    headerAlign?: string;
    showTooltipWhenOverflow?: boolean;
    showOverflowTooltip?: boolean;
    fixed?: boolean | string;
    formatter?: (row: T, column: TableColumnCtx<T>, cellValue: any, index: number) => VNode | string | number;
    selectable?: (row: T, index: number) => boolean;
    reserveSelection?: boolean;
    filterMethod?: FilterMethods<T>;
    filteredValue?: string[];
    filters?: Filters;
    filterPlacement?: string;
    filterMultiple?: boolean;
    index?: number | ((index: number) => number);
    sortOrders?: ('ascending' | 'descending' | null)[];
    renderCell?: (data: any) => void;
    colSpan?: number;
    rowSpan?: number;
    children?: TableColumnCtx<T>[];
    level?: number;
    filterable?: boolean | FilterMethods<T> | Filters;
    order?: string;
    isColumnGroup?: boolean;
    columns?: TableColumnCtx<T>[];
    getColumnIndex?: () => number;
    no?: number;
}

export interface Iwsmsg {
    Emit: 'match' | 'runcode'
    msg: 'match' | 'runcode'
    data: unknown
}

export type Ilang = 'CPP' | 'C++' | 'Python' | 'C'


type Ivalidate = (isValid?: boolean, invalidFields?: ValidateFieldsError) => void

export interface MyElForm {
    validate: (cb: Ivalidate) => void;
    resetFields: () => void;
    clearValidate: (props?: string | string[]) => void;
    validateField: (props: string | string[], cb: (isValid?: boolean, invalidFields?: ValidateFieldsError) => void) => void;
    scrollToField: (prop: string) => void;
}

export type EMstatus = 'wait' | 'process' | 'finish' | 'error' | 'success'


export type IDate = { type: string, count: number, day: string }